<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sugar</title>
  <style>
    .blue {
      height: 50px;
      margin: 10px 0;
    }

    .blue {
      background: blue;
    }

    .red-outer {
      height: 100px;
      background: orange;
      overflow: hidden;
    }

    .red-inner {
      /* 创建新的BFC避免相邻 <div> 之间的 外边距合并 问题 */
      margin: 20px 0;
      height: 30px;
      background-color: red;
    }
  </style>
</head>

<body>
  <h1>蓝色盒子的下边距和红色盒子的上边距合并了</h1>
  <div class="blue">蓝色盒子</div>
  <div class="red-outer">
    <div class="red-inner">红色盒子内容</div>
  </div>
</body>

</html>